package visitor;

import operators.Cat;
import operators.Minus;
import operators.Plus;
import operators.Produs;
import arbore.Constanta;
import arbore.Necunoscuta;
import arbore.Nod;
import arbore.Operator;
import functions.Cos;
import functions.Functie;
import functions.Sin;

public class ToStringVisitor extends Visitor{

	private String s;
	
	public ToStringVisitor(){
		s="";
	}
	public ToStringVisitor(String s) {
		super();
		this.s = s;
	}

	public String getS() {
		return s;
	}

	public void setS(String s) {
		this.s = s;
	}

	public void visit(Plus p) {
		if(p.getfStang()!=null && p.getfDrept()!=null){
			visit(p.getfStang());
			String s1=this.s;
			visit(p.getfDrept());
			String s2=this.s;
			s=p.concatTermeni(s1,s2);
		}
	}

	public void visit(Minus m) {
		if(m.getfStang()!=null && m.getfDrept()!=null){
			visit(m.getfStang());
			String s1=this.s;
			visit(m.getfDrept());
			String s2=this.s;
			s=m.concatTermeni(s1,s2);
		}
	}

	public void visit(Cat m) {		
		if(m.getfStang()!=null && m.getfDrept()!=null){
			visit(m.getfStang());
			String s1=this.s;
			visit(m.getfDrept());
			String s2=this.s;
			s=m.concatTermeni(s1,s2);
		}
	}

	public void visit(Produs p) {	
		if(p.getfStang()!=null && p.getfDrept()!=null){
			visit(p.getfStang());
			String s1=this.s;
			visit(p.getfDrept());
			String s2=this.s;
			s=p.concatTermeni(s1,s2);
		}
	}

	public void visit(Necunoscuta n) {
		this.s="x";
	}

	public void visit(Constanta c) {
		this.s=Double.toString(c.getCt());
	}

	public void visit(Sin p) {
		if(p.getfStang()!=null){
			visit(p.getfStang());
			String s1=this.s;
			s=p.concatTermeni(s1);
		}
	}

	public void visit(Cos p) {
		if(p.getfStang()!=null){
			visit(p.getfStang());
			String s1=this.s;
			s=p.concatTermeni(s1);
		}
	}
	public void visit(Functie f){
		
	}
	
	public void visit(Operator o){
		
	}
	public void visit(Nod n) {
		visit(n);
			
	}

}
